<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: GiantM
  Date: 2018/3/7
  Time: 17:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <base href="<%= request.getContextPath()%>/">
    <link href="bootstrap/dist/css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-xs-12 col-md-4">配件列表</div>
    </div>
    <%--<div class="row">
        <div class="col-xs-12 col-md-4">
            <a href="carparts/preAdd/刹车片">
                <button type="button" class="btn btn-danger btn-sm glyphicon glyphicon-pencil"> 添加配件</button>
            </a>
        </div>
    </div>--%>

    <table class="table table-hover">
        <tr>
            <th>编号</th>
            <th>图片</th>
            <th>名称</th>
            <th>型号</th>
            <th>零件数量</th>
            <th>供应商</th>
            <%--<th>地址</th>--%>
           <%-- <th>供应商联系人</th>
            <th>供应商电话</th>--%>
            <th>销售单价</th>
            <th>采购单价</th>
            <c:choose>
                <c:when test="${rolename=='admin'}">
                    <th>操作</th>
                </c:when>
            </c:choose>
        </tr>
        <c:forEach var="c" items="${cars}">
            <tr>
                <td>${c.pieceId}</td>
                <td>
                    <img src="show/${c.piecePic}" alt="..." class="img-rounded" width="50px" >
                </td>
                <td>${c.pieceName}</td>
                <td>${c.pieceEname}</td>
                <td>${c.pieceNum}</td>
                <td>${c.pieceSupply}</td>
                <%--<td>${c.supplyAddress}</td>--%>
                <%--<td>${c.supplyPerson}</td>
                <td>${c.supplyTel}</td>--%>
                <td>${c.priceDan}</td>
                <td>${c.priceCai}</td>
                <c:choose>
                    <c:when test="${rolename=='admin'}">
                        <td>
                            <a href="carparts/delete/${c.pieceId}/${name}">
                                <button  class="btn btn-success btn-sm glyphicon glyphicon-trash"> 删除</button>
                            </a>
                            <a href="carparts/preUpdate/${c.pieceId}/${name}/${p.pageNum}">
                                <button class="btn btn-info btn-sm glyphicon glyphicon-refresh"> 更新</button>
                            </a>

                            <button type="button" class="btn btn-primary btn-sm" data-container="body" data-toggle="popover" data-placement="left" data-content="${c.supplyAddress} ${c.supplyPerson} ${c.supplyTel}">
                                联系供应商
                            </button>
                        </td>
                    </c:when>
                </c:choose>
            </tr>
        </c:forEach>
    </table>
    <div class="row">
        <div class=""col-md-8">
        <%--隐藏域保存当前页数--%>
        <input type="hidden" name="pages" value="1">
        当前<span class="badge">${p.pageNum}</span>页数，共<span class="badge">${p.pages}</span>页，总<span class="badge">${p.total}</span>条记录
    </div>
    <div class="col-md-6 col-md-offset-3">
        <nav aria-label="Page navigation">
            <ul class="pagination">
                <li ><a href="carparts/alllist/${name}/1">首页</a></li>
                <c:if test="${p.hasPreviousPage}">
                    <li>
                        <a href="carparts/alllist/${name}/${p.pageNum-1}" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>

                <c:forEach items="${p.navigatepageNums}" var="page_num">
                    <c:if test="${page_num == p.pageNum}">
                        <li class="active"><a href="carparts/alllist/${name}/${page_num}">${page_num}</a></li>
                    </c:if>
                    <c:if test="${page_num != p.pageNum}">
                        <li ><a href="carparts/alllist/${name}/${page_num}">${page_num}</a></li>
                    </c:if>

                </c:forEach>

                <c:if test="${p.hasNextPage}">
                    <li>
                        <a href="carparts/alllist/${name}/${p.pageNum+1}" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>

                <li ><a href="carparts/alllist/${name}/${p.pages}">末页</a></li>
            </ul>
        </nav>
    </div>
</div>
</div>
</body>
</html>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script src="bootstrap/dist/js/bootstrap.js"></script>
<script>
    $(function (){
        $("[data-toggle='popover']").popover();
    });
</script>
</script>
